<?php

namespace common\models;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "{{%category}}".
 *
 * @property integer $id
 * @property integer $parent_id
 * @property string $cate_name
 * @property integer $order
 * @property integer $visibility
 * @property string $seo_title
 * @property string $seo_keyword
 * @property string $seo_description
 * @property integer $created_at
 * @property integer $updated_at
 */
class Category extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%category}}';
    }

    public function behaviors()
    {
        return [
            TimestampBehavior::className()
        ];
    }


    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['parent_id', 'order', 'visibility', 'created_at', 'updated_at'], 'integer'],
            [['cate_name', 'created_at', 'updated_at'], 'required'],
            [['cate_name'], 'string', 'max' => 50],
            [['seo_title', 'seo_keyword'], 'string', 'max' => 100],
            [['seo_description'], 'string', 'max' => 255]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'id',
            'parent_id' => '上级id',
            'cate_name' => '分类名称',
            'order' => '排序',
            'visibility' => '是否显示',
            'seo_title' => 'SEO标题',
            'seo_keyword' => 'SEO关键词',
            'seo_description' => 'SEO简介',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
        ];
    }
}
